// Suggestion form
FlyTalk.views.MapView = Ext.extend(Ext.form.FormPanel, {
	title: 'Map',
	bodyStyle: 'background: #2f2f2e',
	scroll: false,
	
    initComponent: function () {
		// back button on toolbar
		this.backButton = new Ext.Button({
			text: 'Back',
			ui: 'back',
			handler: this.backButtonTap,
			scope: this
		});
		
		// save button on toolbar
		this.saveButton = new Ext.Button({
			text: 'Send',
			ui: 'action',
			style: 'background: #f7941d',
			handler: this.saveButtonTap,
			scope: this
		});
		
		// top tool bar
		this.composeToolbar = new Ext.Toolbar({
			title: 'Suggestion',
			items:[
				this.backButton,
				{ xtype: 'spacer' },
				this.saveButton,
			]
			
		});

        this.dockedItems = [this.composeToolbar];

        FlyTalk.views.MapView.superclass.initComponent.call(this);
    },	

    backButtonTap: function () {
		this.reset();
//        Ext.dispatch({
//            controller: FlyTalk.controllers.ftController,
//            action: 'openHome'
//        });
		var next = FlyTalk.views.TalkView.tweetToolbar.title; // see which page talk is on right now
		Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'openNext',
            next: next,
        });
    },
    
    saveButtonTap: function () {
		 var message = Ext.getCmp('message').getValue();
		 
		 if(message.length > 140){
			 alert("Comment ("+message.length+" characters) exceeds the 140 character limit.");
		 }else{
			 var user = Ext.getCmp('curUser').getValue();
			 this.reset();
			 Ext.dispatch({
		            controller: FlyTalk.controllers.dbController,
		            action: 'saveSuggestion',
		            uid: user,
		            comment: message,
				});
		 }
    },
   
	
	scroll: true,
	items: [	        
	{ // select a user (researcher mode only!) - THIS FIELD HAS TO BE THE FIRST. DO NOT CHANGE!
	    xtype: 'selectfield',
	    name: 'user',
	    id: 'curUser',
	    label: 'select user',
	    labelWidth: 300,
	    labelAlign: 'top',
	    options: [
{text: 'AnaD',  value: '3'},
{text: 'TAP Airline',  value: '1'},
{text: 'Airport',  value: '2'},
{text: 'Jessica', value: '4'},
{text: 'JoaoDias',  value: '5'},
{text: 'FlyTalk', value: '6'},
{text: 'MariaFreitas',  value: '7'},
{text: 'TruthSlinger',  value: '8'},
{text: 'PradaLvr',  value: '9'},
{text: 'CrazyCanuck', value: '10'},
{text: 'Sugarlicious',  value: '11'},
{text: 'GiveMeKittens',  value: '12'},
{text: 'CRonaldo',  value: '13'},
{text: 'ProfJoe', value: '14'},
{text: 'laItaliana',  value: '15'},
{text: 'Tiagossss', value: '16'},
{text: 'payday',  value: '17'},
{text: 'AmeliaBedelia',  value: '18'},
{text: 'Juliana',  value: '19'},
{text: 'MarisaManuel', value: '20'},
{text: 'VSarmento',  value: '21'},
{text: 'ProperGent', value: '22'},
{text: 'Perfumeire', value: '23'},
{text: 'Lacoste',  value: '24'},
{text: 'Levi', value: '25'},
	    ]
	},//{html: ''},	
    {
    	xtype: 'fieldset',
		title: 'Share how to pass time at the airport',
		style: 'margin-bottom: 1em; margin-top: 0em;',
    },
	{  // textarea for msg
        xtype: 'textareafield',
		id:'message',
        name: 'title',
        labelWidth: 300,
		labelAlign: 'top',
        required: true
    },
    {
    	xtype: 'fieldset',
		title: 'Attach a location',
		style: 'margin-bottom: 1em',
    },
	{
		xtype:'button',
		text: 'Add current location',
		style: 'margin: .5em;',
		ui: 'action'

	},{
		xtype:'button',
		text: 'Add location from map',
		style: 'margin: .5em',
		ui: 'action'
	},
    {
    	xtype: 'fieldset',
		title: 'Add a photo',
		style: 'margin-bottom: 1em',
    },
	{
		xtype:'button',
		text: 'Use photo from camera',
		style: 'margin: .5em',
		ui: 'action'
	},{
		xtype:'button',
		text: 'Upload a photo',
		style: 'margin: .5em',
		ui: 'action'
	},
	]
});

